import Vue from "vue";

// 全局设置
import CONFIGURATION from "@/settings.js";
Vue.prototype.CONF = CONFIGURATION;

import "normalize.css/normalize.css";

// ElementUI
import "element-ui/lib/theme-chalk/index.css";
import Element from "element-ui";
Vue.use(Element);

import "@/styles/index.scss"; // global css
import "@/styles/fonts.scss"; // 全局引入样式
import "@/styles/variables.scss"; // var css

import App from "./App";
import store from "./store";
import router from "./router";

import "@/icons"; // icon
import "@/routerHook"; // permission control

import Manteiaui from "manteia-ui";
// import "manteia-ui/lib/manteiaui.css";
import "manteia-ui/lib/theme-chalk/index.css";
Vue.use(Manteiaui);

// 国际化
import VueI18n from "vue-i18n";
Vue.use(VueI18n);
import I18nConfig from "@/lang";
const i18n = new VueI18n({
  locale: SETTING.lang,
  messages: I18nConfig
});

/* 全局filters注册 */
import * as filters from "./filters"; // 全局filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});

// 接口地址
import Api from "@/api";
Vue.prototype.API = Api;

require("@/mock/index.js"); // mockjs

Vue.prototype._ = require("lodash"); // Lodash

// 全局注册的组件
import MtDictionary from "@/components/mt-dictionary"; // 字典选择组件
import MtListOperate from "@/components/mt-list-operate"; // 列表脚
import MtBreadcrumb from "@/components/mt-breadcrumb"; // 面包屑组件
import MtSearchInput from "@/components/mt-search-input"; // 列表的搜索框
import MtDetailinput from "@/components/mt-detailinput"; // 详情展示项

const install = function(VueClass, opts = {}) {
  if (install.installed) return;
  [
    MtDictionary,
    MtListOperate,
    MtBreadcrumb,
    MtDetailinput,
    MtSearchInput
  ].forEach(plugin => {
    VueClass.use(plugin);
  });
};
Vue.use(install);

// moment
import moment from "@/utils/moment.js";
Vue.prototype.moment = moment;

// Axios
import axios from "@/utils/axios.js";
Vue.prototype.$request = axios;

/* 全局类挂载 */
import Dictionary from "@/class/Dictionary.js"; // 字典类
import LocalStorage from "@/class/LocalStorage.js"; // 本地存储类
Vue.prototype.DICT = new Dictionary();
Vue.prototype.LS = new LocalStorage();

import "@/utils/errorLog"; // 错误捕获

Vue.config.productionTip = false;

new Vue({
  el: "#app",
  router,
  store,
  i18n,
  render: h => h(App)
});
